package com.mofang.powerdekorhelper.activity.mine;

import android.content.Intent;
import android.net.Uri;
import android.view.View;
import android.widget.TextView;

import com.mofang.powerdekorhelper.R;
import com.mofang.powerdekorhelper.base.MvpActivity;
import com.mofang.powerdekorhelper.persenter.AboutPersenter;
import com.mofang.powerdekorhelper.utils.AppUtils;
import com.mofang.powerdekorhelper.utils.Constants;
import com.mofang.powerdekorhelper.utils.T;
import com.mofang.powerdekorhelper.utils.VersionUpdataUtil;
import com.mofang.powerdekorhelper.view.AboutView;
import com.mofang.powerdekorhelper.witget.TitleBar;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by luofei on 2016/7/26 0026.
 */

public class AboutActivity extends MvpActivity<AboutView, AboutPersenter> implements AboutView {

    @BindView(R.id.about_titlebar)
    TitleBar mTitleBar;

    @BindView(R.id.about_vision)
    TextView visionTv;

    @BindView(R.id.about_phone)
    TextView phoneTv;

    @BindView(R.id.about_vision_new)
    TextView aboutVisionNewTv;

    private String phoneNum = Constants.servicePhone;

    @Override
    public void initView() {
        inflateLayout(R.layout.activity_about_layout);
        initTitleBarWithback(mTitleBar, R.string.about);
    }

    @Override
    public void initData() {
        String visionName = AppUtils.getVersionName(this);
        visionTv.setText("v" + visionName);
    }

    @OnClick({R.id.about_phone_continer, R.id.disclaimer_of_liability_continer, R.id.about_vision_continer})
    void OnClick(View view) {
        switch (view.getId()) {

            case R.id.disclaimer_of_liability_continer:
                // 免责声明
                toActivity(this, DisclaimerActivity.class);
                break;

            case R.id.about_vision_continer:

                // 版本更新
                new VersionUpdataUtil(AboutActivity.this, 2).checkVersion();

                break;

            case R.id.about_phone_continer:
                // 客服电话
                Uri uri = Uri.parse("tel:" + phoneNum);

                Intent it = new Intent(Intent.ACTION_DIAL, uri);

                startActivity(it);

                  /*  case R.id.problem_feedback_continer:
                // 帮助反馈
                //toActivity(this, HelpAndFeedBackActivity.class);
                break;*/

                break;
        }
    }

    @Override
    public void showProgress() {

    }

    @Override
    public void hideProgress() {

    }

    @Override
    public void toast(CharSequence s) {
        T.showShort(this, s);
    }

    @Override
    public void toast(int id) {
        T.showShort(this, getResources().getString(id));
    }

    @Override
    public void showNullLayout() {

    }

    @Override
    public void hideNullLayout() {

    }

    @Override
    public void showErrorLayout(View.OnClickListener listener) {

    }

    @Override
    public void hideErrorLayout() {

    }

    @Override
    public void onError(String errorInfo) {

    }

    @Override
    public AboutPersenter initPresenter() {
        return new AboutPersenter();
    }

}
